
<template>
	<!-- 组件-教学计划表格 -->
	<div>
		<el-row :gutter="10" style="margin-top:0.1rem;">
			<el-col :span="2">
				选择时间：
			</el-col>
			<el-col :span="5">
				<weekPicker @callback="pickTime"></weekPicker>
			</el-col>
			<el-col :span="17" style="text-align:right;">
				<el-button @click="visibleWeekRecipes(true)">添加周食谱</el-button>
			</el-col>
		</el-row>
		<table class="table" cellspacing="0" style="width: 100%;margin-top:0.1rem;">
			<thead class="thead">
				<tr>
					<td style="width: 15%;">食品编号</td>
					<td style="width: 15%;">开始时间</td>
					<td style="width: 15%;">结束时间</td>
					<td style="width: 15%;">缩略图</td>
					<td style="width: 20%;">创建时间</td>
					<td style="width: 15%;">操作</td>
				</tr>
			</thead>
			<tbody class="tbody">
				<tr v-for="(item,index) in tableList" :key="index">
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td>
						<el-button type="text" @click="visibleDailyRecipes(3)">每日菜品</el-button>
						<el-button type="text" @click="visibleWeekRecipes(true,item)">编辑</el-button>
						<el-button type="text" @click="deleteRow(item)">删除</el-button>
					</td>
				</tr>
			</tbody>
		</table>
		<el-row>
			<el-pagination
				class="page"
				layout="total, sizes, prev, pager, next, jumper"
				:current-page="searchParam.currPage"
				@size-change="pageSizeChange"
				@current-change="curPageChange"
				:total="searchParam.total"
			></el-pagination>
		</el-row>

		<el-dialog
			:title="addWeekPopup.title"
			:visible.sync="addWeekPopup.visible"
			width="40%">
				<addWeek ref="addWeek" @cancle="visibleWeekRecipes(false)"></addWeek>
		</el-dialog>
	</div>
</template>

<script>
	import weekPicker from '@keer/components/common/week_picker'
	import addWeek from './recipes_add_week'
	export default{
		components:{weekPicker,addWeek},
		data(){
			return {
				searchParam:{
					startTime:'',
					endTime:'',
					currPage:1,
					pageSize:10,
					total:0
				},
				tableList:[{}],
				addWeekPopup:{
					visible:false,
					title:'添加周食谱',
				},
			}
		},
		methods:{
			campusChange : function(campusId) { //校区改变
				
			},
			init(){

			},
			pageSizeChange(val){
				this.searchParam.pageSize=val;
				this.search(1);
			},
			curPageChange(val){
				this.search(val);
			},
			search(pIndex){
				this.searchParam.currPage=pIndex||this.searchParam.currPage;

			},

			pickTime(data){
				this.searchParam.startTime=data[0];
				this.searchParam.endTime=data[1];
			},
			visibleDailyRecipes(val){
				this.$emit('visibleDaily',val);
			},
			deleteRow(item){
				this.$confirm("此操作将删除该食谱, 是否继续?", "温馨提示", {
					confirmButtonText: "确定",
					cancelButtonText: "取消",
					type: "warning",
					center: true
				})
				.then(() => {
					//删除

					// vm.search(1);
				})
				.catch(() => {});
			},
			addWeekRecipes(){
				this.addWeekPopup.title='添加周食谱';
				this.visibleWeekRecipes(true);
			},
			editeWeekRecipes(data){
				this.addWeekPopup.title='编辑周食谱';
				this.visibleWeekRecipes(true,data);
			},
			visibleWeekRecipes(val,data=null){
				this.addWeekPopup.visible=val;

				if(this.$refs['addWeek']){
					this.$refs['addWeek'].init(data);
				}
				else{
					this.$nextTick(()=>{
						this.$refs['addWeek'].init(data);
					})
				}
			},
		},
		mounted(){
			
		},
		computed:{
			
		},
		watch:{

		}
	}
</script>

<style lang="scss" scoped>
	

	/*自定义滚动条样式*/
	// .box-tasks::-webkit-scrollbar {
	// 	// height: 0.08rem;
	// 	width: 0.05rem;
	// }
	// .box-tasks::-webkit-scrollbar-thumb {
	// 	border-radius: 0.5rem;
	// 	background: #BBBBBB;
	// }
	// .box-tasks::-webkit-scrollbar-track {
	// 	background: rgba(242, 246, 252, 0);
	// }	

	
</style>
<style scoped src="@/style/module/table.css"></style>